clear all
* Set root path of replication archieve here 
local path = "~/Box Sync/Shared_EffectofIncarceration_Pennslyvania/Replication Data/"

cd "`path'/PA Sentencing"
cap log close
log using "PASentencingData.log", replace

clear all 
set more off

***********************************************************************
*
* Table 4, Table A2: Different Punishments and 08 and 12 turnout and corrections (full sample) 
*
***********************************************************************

use "sentencingvfreplication.dta", clear

* Full and restricted sample for key variables (main text)

gen delta_turnout=X_GEN_2012_11-X_GEN_2008_11
label var delta_turnout "Change in turnout 2012-2008"

gen delta_corrections=match_corrections2012-match_corrections2008
label var delta_corrections "Change in corrections record 2012-2008"

* Difference in length of sentence between full and restricted sample
sum length_incarceration if o_anyprison == 1
sum length_incarceration if o_anyprison == 1 & restricted_sample == 1

centile length_incarceration if o_anyprison == 1, centile(25 50 75)
centile length_incarceration if o_anyprison == 1 & restricted_sample == 1, centile(25 50 75)

* Full sample
forvalues ctr = 1(1)6 {
 local templabel : label (o_MS_SANCTION) `ctr'
 di "Working on outcome: `templabel'"
 if `ctr'==1 {
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_anyprison == 1, replace bracket ctitle("`templabel'")
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_anyprison ~= 1, append bracket ctitle("All Other Sentences")
 }
 else {
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_MS_SANCTION==`ctr' & o_anyprison ~= 1, append bracket ctitle("`templabel'")
 }
}

* Restricted sample
forvalues ctr = 1(1)6 {
 local templabel : label (o_MS_SANCTION) `ctr'
 di "Working on outcome: `templabel'"
 if `ctr'==1 {
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_anyprison == 1 & restricted_sample == 1, replace bracket ctitle("`templabel'")
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_anyprison ~= 1 & restricted_sample == 1, append bracket ctitle("All Other Sentences")
 }
 else {
  outsum X_GEN_2012_11 X_GEN_2008_11 delta_turnout match_corrections2012 match_corrections2008 delta_corrections /*
  */ using "Table04_PA_KeySummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_MS_SANCTION==`ctr' & o_anyprison ~= 1 & restricted_sample == 1, append bracket ctitle("`templabel'")
 }
}
drop delta_turnout delta_corrections


* Full sample for all variables (appendix)
forvalues ctr = 1(1)6 {
 local templabel : label (o_MS_SANCTION) `ctr'
 di "Working on outcome: `templabel'"
 if `ctr'==1 {
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_anyprison == 1, replace bracket ctitle("`templabel'")
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_anyprison ~= 1, append bracket ctitle("All Other Sentences")
 }
 else {
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelB_FullSample.out" if o_MS_SANCTION==`ctr' & o_anyprison ~= 1, append bracket ctitle("`templabel'")
 }
}

* Restricted sample for all variables (appendix)
forvalues ctr = 1(1)6 {
 local templabel : label (o_MS_SANCTION) `ctr'
 di "Working on outcome: `templabel'"
 if `ctr'==1 {
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_anyprison == 1 & restricted_sample == 1, replace bracket ctitle("`templabel'")
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_anyprison ~= 1 & restricted_sample == 1, append bracket ctitle("All Other Sentences")
 }
 else {
  outsum X_GEN_2012_11-match_correctionsany age2012 ismale-tot_sent_records /*
  */ using "SA_Table02_PA_SummaryStatsbyPunishmnent_PanelA_RestrictedSample.out" if o_MS_SANCTION==`ctr' & o_anyprison ~= 1 & restricted_sample == 1, append bracket ctitle("`templabel'")
 }
}


***********************************************************************
*
* Table 5, Prison sentence and 12 turnout (restricted sample) 
*
* Note that column (1) is again out of order here; In the paper it appears in column 6
*
***********************************************************************

use "sentencingvfreplication.dta", clear
drop X_registered2012 match_corrections2008-match_corrections2012 match_correctionsany /*
*/ o_MS_SANCTION o_multiplecounts o_priorreord tot_sent_records Incarcerated2012 age2012_2 r_countynum

keep if restricted_sample == 1
drop restricted_sample 

* Runs matched pair first (for labeling reasons)
preserve
keep if o_anyprison==0
save "temp_noprisonformerge.dta", replace
restore
keep if o_anyprison==1
rename age2012 age2012_toprison
rename o_guidelinemin  o_guidelinemin_toprison
rename unique_person_id_sent upis
rename X_GEN_2012_11 X_GEN_2012_11_toprison
count
joinby X_registered2008 X_GEN_2008_11 ismale rd_1 rd_2 rd_3 o_ogs o_anyfelony  using "temp_noprisonformerge.dta", unmatched(master)
!erase "temp_noprisonformerge.dta"
tab _merge
drop if _merge~=3

* Now score the age matches
gen agediff=abs(age2012-age2012_toprison)
* require age to be withing 2.5 years on either side (5 year window)
drop if agediff >2.5

*summarize differences in guideline sentences
gen sentdiff=abs(o_guidelinemin_toprison-o_guidelinemin)
* require sentence to be within .25 (3 months)
drop if sentdiff>.25

* Keeps closest in age
* If that is tied, keeps closest in sentence length
* If that is tied, keeps lowest ID number as tiebreaker
gsort upis agediff sentdiff unique_person_id_sent 
count if upis == upis[_n-1] & agediff == agediff[_n-1] & sentdiff == sentdiff[_n-1]
count if upis == upis[_n-1] & agediff == agediff[_n-1] & sentdiff == sentdiff[_n-1] & /*
*/ unique_person_id_sent == unique_person_id_sent[_n-1]  
drop if upis==upis[_n-1]
count

keep upis unique_person_id_sent X_GEN_2012_11 X_GEN_2012_11_toprison age2012 age2012_toprison o_guidelinemin o_guidelinemin_toprison X_GEN_2008_11

rename X_GEN_2012_11 X_GEN_2012_11_1
rename X_GEN_2012_11_toprison X_GEN_2012_11_2
rename age2012 age2012_1
rename age2012_toprison age2012_2
rename o_guidelinemin o_guidelinemin_1
rename o_guidelinemin_toprison o_guidelinemin_2
gen unique_person_id_sent_1 = upis
rename unique_person_id_sent unique_person_id_sent_2

reshape long X_GEN_2012_11_ age2012_ o_guidelinemin_ unique_person_id_sent_, i(upis X_GEN_2008_11) j(treat) 
replace treat=treat-1

rename X_GEN_2012_11_ X_GEN_2012_11
rename treat o_anyprison
rename age2012_ age2012
rename o_guidelinemin_ o_guidelinemin
rename unique_person_id_sent_ unique_person_id_sent

areg X_GEN_2012_11 o_anyprison age2012 o_guidelinemin, absorb(upis) cluster(unique_person_id_sent)
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", replace se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Matched Pairs") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

use "sentencingvfreplication.dta", clear
drop X_registered2012 match_corrections2008-match_corrections2012 match_correctionsany /*
*/ o_MS_SANCTION o_multiplecounts o_priorreord tot_sent_records

keep if restricted_sample == 1
drop restricted_sample 

* County Fixed Effects
quietly tab r_countynum, gen(cd_)
* Drop Allegheny county
drop cd_2 r_countynum

* OGS Fixed Effects
quietly tab o_ogs, gen(ogs_)
* Drop offense gravity score 1
drop ogs_1 o_ogs

* Bivariate regression, assigned to prison
regress X_GEN_2012_11 o_anyprison, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Bivariate Regression") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

* past participation
regress X_GEN_2012_11 o_anyprison X_registered2008 X_GEN_2008_11 , robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Past Participation") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

* demographics
regress X_GEN_2012_11 o_anyprison age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* , robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Demographics") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

* other stuff about crime
regress X_GEN_2012_11 o_anyprison o_anyfelony o_guidelinemin ogs_*, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Crime Characterestics") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

* combined
regress X_GEN_2012_11 o_anyprison X_registered2008 X_GEN_2008_11 age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* o_anyfelony o_guidelinemin ogs_*, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Complete Model") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  

* Removing people who may still be incarcerated in 2012
regress X_GEN_2012_11 o_anyprison X_registered2008 X_GEN_2008_11 age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* o_anyfelony o_guidelinemin ogs_* if Incarcerated2012 == 0, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyprison if e(sample)
local inprison=r(N)*r(mean)
outreg2 using "Table05_PA_EffectofPrisononParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Excluding People Potentially Imprisoned in '12") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated to Prison",`inprison')  


***********************************************************************
*
* Table A5, Jail sentence and 12 turnout (restricted sample) 
*
*
* Note that column (1) is again out of order here; In the paper it appears in column 6
*
***********************************************************************

use "sentencingvfreplication.dta", clear

* Runs matched pair first (for labeling reasons)
drop X_registered2012 match_corrections2008-match_corrections2012 match_correctionsany /*
*/ o_multiplecounts o_priorreord tot_sent_records Incarcerated2012 age2012_2 r_countynum

keep if restricted_sample == 1
drop restricted_sample 

* drops prison and state intermediate punishment
tab o_MS_SANCTION 
drop if o_MS_SANCTION == 1 | o_MS_SANCTION == 2
drop o_anyprison

gen o_anyjail = (o_MS_SANCTION == 3)
drop o_MS_SANCTION 

preserve
keep if o_anyjail==0
save "temp_noprisonformerge.dta", replace
restore
keep if o_anyjail==1
rename age2012 age2012_toprison
rename o_guidelinemin  o_guidelinemin_toprison
rename unique_person_id_sent upis
rename X_GEN_2012_11 X_GEN_2012_11_toprison
count
joinby X_registered2008 X_GEN_2008_11 ismale rd_1 rd_2 rd_3 o_ogs o_anyfelony  using "temp_noprisonformerge.dta", unmatched(master)
!erase "temp_noprisonformerge.dta"
tab _merge
drop if _merge~=3

* Now score the age matches
gen agediff=abs(age2012-age2012_toprison)
* require age to be withing 2.5 years on either side (5 year window)
drop if agediff >2.5

*summarize differences in guideline sentences
gen sentdiff=abs(o_guidelinemin_toprison-o_guidelinemin)
* require sentence to be within .25 (3 months)
drop if sentdiff>.25

* Keeps closest in age
* If that is tied, keeps closest in sentence length
* If that is tied, keeps lowest ID number as tiebreaker
gsort upis agediff sentdiff unique_person_id_sent 
count if upis == upis[_n-1] & agediff == agediff[_n-1] & sentdiff == sentdiff[_n-1]
count if upis == upis[_n-1] & agediff == agediff[_n-1] & sentdiff == sentdiff[_n-1] & /*
*/ unique_person_id_sent == unique_person_id_sent[_n-1]  
drop if upis==upis[_n-1]
count

keep upis unique_person_id_sent X_GEN_2012_11 X_GEN_2012_11_toprison age2012 age2012_toprison o_guidelinemin o_guidelinemin_toprison X_GEN_2008_11

rename X_GEN_2012_11 X_GEN_2012_11_1
rename X_GEN_2012_11_toprison X_GEN_2012_11_2
rename age2012 age2012_1
rename age2012_toprison age2012_2
rename o_guidelinemin o_guidelinemin_1
rename o_guidelinemin_toprison o_guidelinemin_2
gen unique_person_id_sent_1 = upis
rename unique_person_id_sent unique_person_id_sent_2

reshape long X_GEN_2012_11_ age2012_ o_guidelinemin_ unique_person_id_sent_, i(upis X_GEN_2008_11) j(treat) 
replace treat=treat-1

rename X_GEN_2012_11_ X_GEN_2012_11
rename treat o_anyjail
rename age2012_ age2012
rename o_guidelinemin_ o_guidelinemin
rename unique_person_id_ unique_person_id

areg X_GEN_2012_11 o_anyjail age2012 o_guidelinemin, absorb(upis) cluster(unique_person_id)
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", replace se bracket/*
*/ label  dec(3) symbol(***, **, *) ctitle("Matched Pairs") addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* Regression analysis 
use "sentencingvfreplication.dta", clear
drop X_registered2012 match_corrections2008-match_corrections2012 match_correctionsany /*
*/ o_multiplecounts o_priorreord tot_sent_records

keep if restricted_sample == 1
drop restricted_sample 

* drops prison and state intermediate punishment
tab o_MS_SANCTION 
drop if o_MS_SANCTION == 1 | o_MS_SANCTION == 2
drop o_anyprison

gen o_anyjail = (o_MS_SANCTION == 3)
drop o_MS_SANCTION 
label var o_anyjail "Any jail for most serious offense? (1=yes)"

* Checks we have common support on OGS
tab o_ogs o_anyjail 

* County Fixed Effects
quietly tab r_countynum, gen(cd_)
* Drop Allegheny county
drop cd_2 r_countynum

* OGS Fixed Effects
quietly tab o_ogs, gen(ogs_)
* Drop offense gravity score 1
drop ogs_1 o_ogs

* Bivariate regression, assigned to jail
regress X_GEN_2012_11 o_anyjail, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Bivariate Regression") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* past participation
regress X_GEN_2012_11 o_anyjail X_registered2008 X_GEN_2008_11 , robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Past Participation") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* demographics
regress X_GEN_2012_11 o_anyjail age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* , robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Demographics") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* other stuff about crime
regress X_GEN_2012_11 o_anyjail o_anyfelony o_guidelinemin ogs_*, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Crime Characterestics") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* combined
regress X_GEN_2012_11 o_anyjail X_registered2008 X_GEN_2008_11 age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* o_anyfelony o_guidelinemin ogs_*, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Complete Model") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

* Removing people who may still be incarcerated in 2012
regress X_GEN_2012_11 o_anyjail X_registered2008 X_GEN_2008_11 age2012 age2012_2 ismale rd_2 rd_3 rd_1 cd_* o_anyfelony o_guidelinemin ogs_* if Incarcerated2012 == 0, robust
qui summ X_GEN_2012_11 if e(sample)
local vote12=r(mean)
qui summ X_GEN_2008_11 if e(sample)
local vote08=r(mean)
qui summ o_anyjail if e(sample)
local injail=r(N)*r(mean)
outreg2 using "SA_Table05_PA_EffectofJailonParticipation_RestrictedSample.out", append se bracket label /*
*/ dec(3) symbol(***, **, *) ctitle("Excluding People Potentially Imprisoned in '12") /*
*/ addnote("Note: Cell entries are OLS estimates with robust standard errors in brackets. *p<.1; **p<.05; ***p<.01.") /*
*/ addstat("Prop. Voting 2012",`vote12',"Prop. Voting 2008",`vote08',"Number Treated To Jail",`injail')  

log close
